package com.zone.service.controller;

import java.util.List;
import java.io.IOException;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zone.common.log.annotation.Log;
import com.zone.common.log.enums.BusinessType;
import com.zone.common.security.annotation.RequiresPermissions;
import com.zone.service.domain.FixZswsRoute;
import com.zone.service.service.IFixZswsRouteService;
import com.zone.common.core.web.controller.BaseController;
import com.zone.common.core.web.domain.AjaxResult;
import com.zone.common.core.utils.poi.ExcelUtil;
import com.zone.common.core.web.page.TableDataInfo;

/**
 * 固定线路Controller
 * 
 * @author liuyang
 * @date 2025-11-18
 */
@RestController
@RequestMapping("/fixZswsRoute")
public class FixZswsRouteController extends BaseController
{
    @Autowired
    private IFixZswsRouteService fixZswsRouteService;

    /**
     * 查询固定线路列表
     */
    @RequiresPermissions("service:fixZswsRoute:list")
    @GetMapping("/list")
    public TableDataInfo list(FixZswsRoute fixZswsRoute)
    {
        startPage();
        List<FixZswsRoute> list = fixZswsRouteService.selectFixZswsRouteList(fixZswsRoute);
        return getDataTable(list);
    }

    /**
     * 导出固定线路列表
     */
    @RequiresPermissions("service:fixZswsRoute:export")
    @Log(title = "固定线路", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FixZswsRoute fixZswsRoute)
    {
        List<FixZswsRoute> list = fixZswsRouteService.selectFixZswsRouteList(fixZswsRoute);
        ExcelUtil<FixZswsRoute> util = new ExcelUtil<FixZswsRoute>(FixZswsRoute.class);
        util.exportExcel(response, list, "固定线路数据");
    }

    /**
     * 获取固定线路详细信息
     */
    @RequiresPermissions("service:fixZswsRoute:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fixZswsRouteService.selectFixZswsRouteById(id));
    }

    /**
     * 新增固定线路
     */
    @RequiresPermissions("service:fixZswsRoute:add")
    @Log(title = "固定线路", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FixZswsRoute fixZswsRoute)
    {
        return toAjax(fixZswsRouteService.insertFixZswsRoute(fixZswsRoute));
    }

    /**
     * 修改固定线路
     */
    @RequiresPermissions("service:fixZswsRoute:edit")
    @Log(title = "固定线路", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FixZswsRoute fixZswsRoute)
    {
        return toAjax(fixZswsRouteService.updateFixZswsRoute(fixZswsRoute));
    }

    /**
     * 删除固定线路
     */
    @RequiresPermissions("service:fixZswsRoute:remove")
    @Log(title = "固定线路", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fixZswsRouteService.deleteFixZswsRouteByIds(ids));
    }
}
